package com.company.creational.factory_pattern.demo.factory;

import com.company.creational.factory_pattern.demo.product.ConcreteProductA;
import com.company.creational.factory_pattern.demo.product.ConcreteProductB;
import com.company.creational.factory_pattern.demo.product.Product;

/**
 * @ClassName Factory
 * @Author tiezheng.han
 * @Date 2020/8/26 10:20
 **/
public class Factory {

    private static final String A = "Matrix";
    private static final String B = "B";

    /**
     * 静态工厂方法
     * @param arg
     * @return
     */
    public static Product getProduct(String arg){
        Product product = null;
        if (arg.equalsIgnoreCase(A)){
            product = new ConcreteProductA();
            //初始化设置product
        } else if (arg.equalsIgnoreCase(B)){
            product = new ConcreteProductB();
            //初始化设置product
        }
        return product;
    }
}
